<?php
/********************************************************************
You can add your filetes in this file and it will affected.
This is the common filter functions file where you can add you filtes.
********************************************************************/
add_filter('templ_theme_guide_link_filter','templ_theme_guide_link_fun');
function templ_theme_guide_link_fun($guidelink)
{
	$guidelink = "http://templatic.com/theme-support/theme-documentation/private-lawyer-theme-guide"; // templatic.com site theme guide url here
	return $guidelink;
}

add_filter('templ_theme_forum_link_filter','templ_theme_forum_link_fun');
function templ_theme_forum_link_fun($forumlink)
{
	$forumlink = "http://templatic.com/forums/viewforum.php?f=64"; // templatic.com site Forum url here
	return $forumlink;
}

add_filter('templ_sidebar_widget_box_filter','templ_sidebar_widget_box_fun'); 
function templ_sidebar_widget_box_fun($content)
{
	//print_r($content);
	//die;
	$content['top_navigation_above']='';
	$content['main_navigation']='';
	$content['header_above']='';
	$content['header_logo_right_side']='';
	$content['container_below']='';
	$content['slider_above']='';
	$content['slider_below']='';
	$content['header_logo_right_side']='';
	$content['bottom_2column_equal_left']=''; 
	$content['bottom_2column_equal_right']='';
	$content['bottom_2column_left']=''; 
	$content['bottom_2column_right']='';
	$content['bottom_3column_first']='';
	$content['bottom_3column_second']=''; 
	$content['bottom_3column_third']='';
	$content['bottom_4column_first']='';
	$content['bottom_4column_second']='';
	$content['bottom_4column_third']='';
	$content['bottom_4column_fourth']='';
	$content['bottom_full_width']='';
	$sidebar_widget_arr = array();
	$sidebar_widget_arr['front_page_content'] =array(1,array('name' => 'Front Page Content','id' => 'front_page_content','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));
	array_splice($content, 1, 0, $sidebar_widget_arr);
	$sidebar_widget_arr = array();
	$sidebar_widget_arr['inner_page_sidebar_left'] =array(1,array('name' => 'Inner Page Sidebar Left','id' => 'inner_page_sidebar_left','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));
	$sidebar_widget_arr['inner_page_sidebar_right'] =array(1,array('name' => 'Inner Page Sidebar Right','id' => 'inner_page_sidebar_right','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));
	array_splice($content, count($content)-1, 0, $sidebar_widget_arr);
	
	
	
		
	//print_r($content);
	
	return $content;
}
add_filter('templ_widgets_listing_filter','templ_widgets_listing_fun');
function templ_widgets_listing_fun($content)
{
	$content['featured_video']='';
	$content['pika_choose_slider']='';
	$content['anything_slider']='';
	$content['anything_listing_slider']='';
	$content['nivo_slider']='';
	$content['social_media']='';
	
	//print_r($content);
	//$content['flickr']='';
	return $content;
}

add_filter('templ_admin_menu_title_filter','templ_admin_menu_title_fun');
function templ_admin_menu_title_fun($content)
{
	return $content=__('Private Lawyer','templatic');
}

/////////search widget filter start/////////////
add_action('pre_get_posts', 'search_filter');
function search_filter($local_wp_query) 
{
	if(is_search())
	{
		add_filter('posts_where', 'searching_filter_where');
	}
}
function searching_filter_where($where) {
	global $wpdb;
	$scat = trim($_REQUEST['catdrop']);
	$todate = trim($_REQUEST['todate']);
	$frmdate = trim($_REQUEST['frmdate']);
	$articleauthor = trim($_REQUEST['articleauthor']);
	$exactyes = trim($_REQUEST['exactyes']);
	if($scat>0)
	{
		$where .= " AND  $wpdb->posts.ID in (select $wpdb->term_relationships.object_id from $wpdb->term_relationships join $wpdb->term_taxonomy on $wpdb->term_taxonomy.term_taxonomy_id=$wpdb->term_relationships.term_taxonomy_id and $wpdb->term_taxonomy.term_id=\"$scat\" ) ";
	}
	if($todate!="" && $frmdate=="")
	{
		$where .= " AND   DATE_FORMAT($wpdb->posts.post_date,'%Y-%m-%d') >='".$todate."'";
	}
	else if($frmdate!="" && $todate=="")
	{
		
		$where .= " AND  DATE_FORMAT($wpdb->posts.post_date,'%Y-%m-%d') <='".$frmdate."'";
	}
	else if($todate!="" && $frmdate!="")
	{
		$where .= " AND  DATE_FORMAT($wpdb->posts.post_date,'%Y-%m-%d') BETWEEN '".$todate."' and '".$frmdate."'";
		
	}
	if($articleauthor!="" && $exactyes!=1)
	{
		$where .= " AND  $wpdb->posts.post_author in (select $wpdb->users.ID from $wpdb->users where $wpdb->users.display_name  like '".$articleauthor."') ";
	}
	if($articleauthor!="" && $exactyes==1)
	{
		$where .= " AND  $wpdb->posts.post_author in (select $wpdb->users.ID from $wpdb->users where $wpdb->users.display_name  = '".$articleauthor."') ";
	}
	//echo $where;
	return $where;
}
/////////search widget filter end/////////////
?>